package org.jeecg.modules.param.member.service.impl;

import cn.hutool.core.util.PageUtil;
import com.alipay.api.response.AlipayTradeFastpayRefundQueryResponse;
import com.alipay.api.response.AlipayTradeRefundResponse;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.modules.approve.cancel.entity.BikeApproveCancel;
import org.jeecg.modules.approve.cancel.mapper.BikeApproveCancelMapper;
import org.jeecg.modules.bicycle.order.entity.BikeVehicleOrder;
import org.jeecg.modules.bicycle.order.mapper.BikeVehicleOrderMapper;
import org.jeecg.modules.bicycle.order.vo.Refund;
import org.jeecg.modules.bicycle.vehicle.entity.BikeVehicle;
import org.jeecg.modules.constant.BikeConstant;
import org.jeecg.modules.param.charge.entity.BikeMemberUserCharge;
import org.jeecg.modules.param.charge.mapper.BikeMemberUserChargeMapper;
import org.jeecg.modules.param.member.entity.BikeMemberUser;
import org.jeecg.modules.param.member.entity.BikeMemberUserCard;
import org.jeecg.modules.param.member.mapper.BikeMemberUserCardMapper;
import org.jeecg.modules.param.member.mapper.BikeMemberUserMapper;
import org.jeecg.modules.param.member.service.IBikeMemberUserService;
import org.jeecg.modules.param.member.vo.MemberStatisticsReq;
import org.jeecg.modules.param.member.vo.MemberStatisticsRsp;
import org.jeecg.modules.param.member.vo.SysUserRes;
import org.jeecg.modules.param.member.vo.UserCard;
import org.jeecg.modules.param.refund.entity.BikeMemberUserReturn;
import org.jeecg.modules.param.refund.mapper.BikeMemberUserReturnMapper;
import org.jeecg.modules.param.spend.entity.BikeMemberUserSpend;
import org.jeecg.modules.param.spend.mapper.BikeMemberUserSpendMapper;
import org.jeecg.modules.system.permissions.entity.BikeSysUserApp;
import org.jeecg.modules.system.permissions.mapper.BikeSysUserAppMapper;
import org.jeecg.modules.system.upgrade.mapper.BikeUpgradeAppMapper;
import org.jeecg.modules.utils.*;
import org.jeecg.modules.utils.page.PageInfo;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.swing.*;
import java.io.Serializable;
import java.lang.annotation.ElementType;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @Description: 会员用户管理
 * @Author: 月月鸟
 * @Date:   2021-05-25
 * @Version: V1.0
 */
@Service
public class BikeMemberUserServiceImpl extends ServiceImpl<BikeMemberUserMapper, BikeMemberUser> implements IBikeMemberUserService {

	@Resource
	private BikeMemberUserMapper bikeMemberUserMapper;
	@Resource
	private BikeMemberUserCardMapper bikeMemberUserCardMapper;
	@Resource
	private BikeVehicleOrderMapper bikeVehicleOrderMapper;
	@Resource
	private BikeMemberUserReturnMapper bikeMemberUserReturnMapper;
	@Autowired
	private RedisUtil redisUtil;
	@Resource
	private BikeMemberUserSpendMapper bikeMemberUserSpendMapper;
	@Resource
	private BikeMemberUserChargeMapper bikeMemberUserChargeMapper;
	@Resource
	private BikeSysUserAppMapper bikeSysUserAppMapper;
	@Resource
	private BikeApproveCancelMapper bikeApproveCancelMapper;

	@Override
	@Transactional
	public void delMain(String id) {
		bikeMemberUserCardMapper.deleteByMainId(id);
		bikeMemberUserMapper.deleteById(id);
	}

	@Override
	@Transactional
	public void delBatchMain(Collection<? extends Serializable> idList) {
		for(Serializable id:idList) {
			bikeMemberUserCardMapper.deleteByMainId(id.toString());
			bikeMemberUserMapper.deleteById(id);
		}
	}

	@Override
	public PageInfo pageList(Integer pageNo, Integer pageSize, UserCard userCard) {
		Page<UserCard> userCards = bikeMemberUserMapper.pageList(new Page<>(pageNo,pageSize),userCard);
		List<UserCard> records = userCards.getRecords();
		//添加骑行状态
		for (UserCard tb :records) {
			if (StringUtils.isEmpty(tb.getUserRideStatus())){
				tb.setUserRideStatus(BikeConstant.ride_status_not);
			}
		}
		PageInfo pageInfo = new PageInfo();
		pageInfo.setSize(userCards.getSize());
		pageInfo.setTotal(userCards.getTotal());
		pageInfo.setRecords(records);
		pageInfo.setCurrent(userCards.getCurrent());
		return pageInfo;
	}
	@Override
	public List<UserCard> queryPageListById(Integer pageNo, Integer pageSize, UserCard userCard) {
		return bikeMemberUserMapper.queryPageListById(userCard.getId());

	}



	//编辑用户
	@Override
	public Result<?> editUser(BikeMemberUser bikeMemberUser) {
		if (StringUtils.isNotEmpty(bikeMemberUser.getIsCertification()))
		bikeMemberUserMapper.updateById(bikeMemberUser);

		return Result.OK("修改成功!");
	}
	@Override
	public boolean checkPhone(String phone) {
		//判断新手机号是否重复
		QueryWrapper<BikeMemberUser> wrapper = new QueryWrapper<>();
		wrapper.eq("code",phone);
		wrapper.ne("status","4");
		BikeMemberUser memberUser = bikeMemberUserMapper.selectOne(wrapper);
		//判断是否为空
		return memberUser == null;
	}
	@Override
	public Result<?> changePhone(BikeMemberUser bikeMemberUser) {
		//判断新手机号是否重复
		QueryWrapper<BikeMemberUser> wrapper = new QueryWrapper<>();
		if (StringUtils.isEmpty(bikeMemberUser.getPhone())){
			return Result.error("请输入手机号");
		}
		wrapper.eq("code",bikeMemberUser.getPhone());
		wrapper.ne("status","4");
		BikeMemberUser memberUser = bikeMemberUserMapper.selectOne(wrapper);
		//判断是否为空
		if (memberUser!=null){
			if (!memberUser.getId().equals(bikeMemberUser.getId())){
				return Result.error("手机号已被注册！");
			}
		}
		//判断验证码
		//TODO: 2021/5/27 暂时不验证
		if (StringUtils.isNotEmpty(bikeMemberUser.getSmsCode())){
			String o = (String) redisUtil.get(bikeMemberUser.getPhone());
			if (StringUtils.isEmpty(o)){
				return Result.error("请重新发送验证码");
			}
			if (!o.equals(bikeMemberUser.getSmsCode())){
				return Result.error("验证码错误!");
			}
		}else {
			return Result.error("请输入验证码");
		}
		//验证成功后
		redisUtil.del(bikeMemberUser.getPhone());

		bikeMemberUser.setCode(bikeMemberUser.getPhone());
		bikeMemberUserMapper.updateById(bikeMemberUser);
		return Result.OK("改绑完成");
	}
	/**
	 * 会员借车次数统计
	 */
	@Override
	public List<MemberStatisticsRsp> statistics(List<BikeMemberUser> records, MemberStatisticsReq memberStatisticsReq) {
		if (records != null && !records.isEmpty()) {
			List<MemberStatisticsRsp> rspList = new ArrayList<>();
			for (BikeMemberUser tb : records) {
				MemberStatisticsRsp memberStatisticsRsp = MemberUserGoStatisticsRsp(tb);
				memberStatisticsReq.setUserId(tb.getId());
				//获取充值总金额
				memberStatisticsRsp.setChargeSum(getChargeSum(memberStatisticsReq));
				//后续数据
				Map<String,Object> map = getStatisticsLow(memberStatisticsReq);
				memberStatisticsRsp.setLendCount((Integer) map.get("lendCount"));
				memberStatisticsRsp.setSweepCount((Integer) map.get("sweepCount"));
				memberStatisticsRsp.setBrushCount((Integer) map.get("brushCount"));
				memberStatisticsRsp.setUseHHMM((String) map.get("useHHMM"));
				memberStatisticsRsp.setTotalAmount(BigDecimal.valueOf((double) map.get("totalAmount")));
				rspList.add(memberStatisticsRsp);

			}
			return rspList;
		}
		return null;
	}

	@Override
	public void checkPayOrderByUserId(String userId) {
		BikeMemberUser bikeMemberUser = bikeMemberUserMapper.selectById(userId);
		//查询已还车，未支付订单
		BikeVehicleOrder bikeVehicleOrder = bikeVehicleOrderMapper.selectOne(new QueryWrapper<BikeVehicleOrder>()
				.eq("pick_user", userId)
				.isNotNull("stop_time")
				.eq("is_pay", BikeConstant.y_n_no));
		if (bikeMemberUser.getBalance().compareTo(bikeVehicleOrder.getPayCost()) > -1) {
			//余额支付
			bikeMemberUser.setBalance(bikeMemberUser.getBalance().subtract(bikeVehicleOrder.getPayCost()));
			bikeMemberUserMapper.updateById(bikeMemberUser);
			//支付完成修改车辆借还记录的状态
			bikeVehicleOrder.setPayActual(bikeVehicleOrder.getPayCost());
			bikeVehicleOrder.setIsPay("1");
			bikeVehicleOrder.setRideStatus("5");
			bikeVehicleOrder.setBillStatus("4");
			bikeVehicleOrderMapper.updateById(bikeVehicleOrder);
			//付款记录
			BikeMemberUserSpend bikeMemberUserSpend = new BikeMemberUserSpend();
			bikeMemberUserSpend.setOrderId(bikeVehicleOrder.getId());
			bikeMemberUserSpend.setUserId(bikeMemberUser.getId());
			bikeMemberUserSpend.setSpendAmount(bikeVehicleOrder.getPayCost());
			bikeMemberUserSpend.setBalanceEnd(bikeMemberUser.getBalance().subtract(bikeVehicleOrder.getPayCost()));
			bikeMemberUserSpend.setSpendType("1");
			bikeMemberUserSpend.setMemo("单车骑行费用");
			bikeMemberUserSpendMapper.insert(bikeMemberUserSpend);
		}
	}



	/**
	 * 会员借车次数统计 后续数据
	 */
	private Map<String,Object> getStatisticsLow(MemberStatisticsReq memberStatisticsReq) {
		Map<String, Object> map = new HashMap<>();
		int lendCount = 0;
		int sweepCount = 0;
		int brushCount = 0;
		int useLong = 0;
		double totalAmount = 0;
		//骑行记录获取
		List<BikeVehicleOrder> bikeVehicleOrder=bikeVehicleOrderMapper.getBikeOrderLendByUserId(memberStatisticsReq);
		if (bikeVehicleOrder!=null&&!bikeVehicleOrder.isEmpty()){
			//借车次数
			lendCount=bikeVehicleOrder.size();
			for (BikeVehicleOrder tb : bikeVehicleOrder){
				//扫码骑行次数
				if (tb.getUseType().equals("1")){
					sweepCount++;
				}
				//刷卡骑行次数
				if (tb.getUseType().equals("2")){
					brushCount++;
				}
				//用车时长(分钟)
				if (tb.getUseLong()!=null){
					if (useLong!=0){
						useLong=useLong+tb.getUseLong();
					}else {
						useLong=tb.getUseLong();
					}
				}
				//消费金额
				if (tb.getPayActual()!=null){
					if (totalAmount!=0){
						totalAmount=totalAmount+tb.getPayActual().doubleValue();
					}else {
						totalAmount=tb.getPayActual().doubleValue();
					}
				}

			}
		}

		//借车次数
		map.put("lendCount",lendCount);
		//扫码骑行次数
		map.put("sweepCount",sweepCount);
		//刷卡骑行次数
		map.put("brushCount",brushCount);
		//用车时长(分钟)
		map.put("useHHMM", CostUtils.MMss(useLong));
		//消费金额
		map.put("totalAmount",totalAmount);
		return map;
	}

	/**
	 * 获取充值总金额
	 */
	private BigDecimal getChargeSum(MemberStatisticsReq memberStatisticsReq) {
		Integer sum=bikeMemberUserChargeMapper.getChargeSum(memberStatisticsReq);
		if (sum == null){
			return new BigDecimal(0);
		}
		return new BigDecimal(sum);
	}

	/**
	 * BikeMemberUser转MemberStatisticsRsp
	 */
	private MemberStatisticsRsp MemberUserGoStatisticsRsp(BikeMemberUser tb) {
		MemberStatisticsRsp memberStatisticsRsp = new MemberStatisticsRsp();
		if (StringUtils.isNotEmpty(tb.getId())){
			memberStatisticsRsp.setId(tb.getId());

		}
		if (StringUtils.isNotEmpty(tb.getCode())){
			memberStatisticsRsp.setCode(tb.getCode());

		}
		if (StringUtils.isNotEmpty(tb.getName())){
			memberStatisticsRsp.setName(tb.getName());
		}
		if (StringUtils.isNotEmpty(tb.getSex())){
			memberStatisticsRsp.setSex(tb.getSex());
		}
		if (StringUtils.isNotEmpty(tb.getIdCard())){
			memberStatisticsRsp.setIdCard(tb.getIdCard());

		}
		if (tb.getBalance()!=null){
			memberStatisticsRsp.setBalance(tb.getBalance());
		}
		return memberStatisticsRsp;
	}

	@Override
	public List<UserCard> needList(UserCard userCard) {
		List<UserCard> userCards = bikeMemberUserMapper.list(userCard);
		//添加骑行状态
		for (UserCard tb :userCards) {
			if (StringUtils.isEmpty(tb.getUserRideStatus())){
				tb.setUserRideStatus(BikeConstant.ride_status_not);
			}
		}
		return userCards;
	}

	@Override
	public Result<?> activate(BikeMemberUser memberUser) {
		BikeMemberUser memberUser1 = bikeMemberUserMapper.selectById(memberUser);
		if (!memberUser1.getStatus().equals(BikeConstant.member_status_logout)&&!memberUser1.getStatus().equals(BikeConstant.member_status_blacklist)){
			return Result.error("注销或黑名单才能激活") ;
		}
		if (memberUser1.getStatus().equals("4")){
			Integer selectCount = bikeMemberUserMapper.selectCount(new QueryWrapper<BikeMemberUser>().ne("status", "4").eq("code", memberUser1.getCode()));
			if (selectCount!=0){
				return Result.error("该账号已被重新注册，无法激活");
			}
		}
		bikeMemberUserMapper.updateById(memberUser);
		return Result.OK("添加成功");
	}

	@Override
	public Result<?> listAdmin(SysUserRes sysUserRes, Integer pageNo, Integer pageSize) {

		List<SysUserRes> sysUserRes1 = bikeMemberUserMapper.listAdminByApp(sysUserRes);
		return Result.OK(sysUserRes1);
		////获取app端的角色权限
		//QueryWrapper<BikeSysUserApp> wrapper = new QueryWrapper<>();
		////获取app权限的类型
		//if (StringUtils.isNotEmpty(sysUserRes.getAppType())){
		//	wrapper.like("role_menu",sysUserRes.getAppType());
		//}
		////只查询有 保洁，维修，调度工单权限的角色
		//List<BikeSysUserApp> bikeSysUserAppList = bikeSysUserAppMapper.selectList(wrapper);
		//String role = null;
		//for (int i = 0 ; i < bikeSysUserAppList.size();i++){
		//	BikeSysUserApp bikeSysUserApp = bikeSysUserAppList.get(i);
		//	if (role==null){
		//		role = bikeSysUserApp.getRoleId();
		//	}else {
		//		role = role + "," + bikeSysUserApp.getRoleId();
		//	}
		//}
		//if (role != null){
		//	String[] roles = role.split(",");
		//	sysUserRes.setRoles(roles);
		//	List<SysUserRes> sysUserRes1 = bikeMemberUserMapper.listAdmin(sysUserRes);
		//	//去重
		//	for (int i = 0; i < sysUserRes1.size() - 1; i++) {
		//		// 从list中索引为 list.size()-1 开始往前遍历
		//		for (int j = sysUserRes1.size() - 1; j > i; j--) {
		//			// 进行比较
		//			if (sysUserRes1.get(j).getId().equals(sysUserRes1.get(i).getId())) {
		//				// 去重
		//				sysUserRes1.remove(j);
		//			}
		//		}
		//	}
	}


	/**
	 * 卡用户销户前 得先把卡退了  根据用户类型判断 支付宝还是现金退款  绑定卡时改为ic类型，退款不改状态
	 * */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public Result<?> refund(BikeMemberUser memberUser) {

		BikeMemberUser memberData = bikeMemberUserMapper.selectById(memberUser);
		//需要退款金额
		BigDecimal refundSum = memberData.getBalance();
		//判断状态是否正常
		if (!memberData.getStatus().equals("1")){
			Result.error("正常状态才能销户");
		}

		//判断是否有卡
		QueryWrapper<BikeMemberUserCard> wrapper = new QueryWrapper<>();
		wrapper.eq("user_id",memberData.getId());
		BikeMemberUserCard userCard = bikeMemberUserCardMapper.selectOne(wrapper);
		//有卡则 退卡，并现在退卡
		if (userCard!=null){
			//退卡
			userCard.setUserType(null);
			userCard.setUserType(null);
			userCard.setCardTime(null);
			userCard.setCardLossTime(null);
			userCard.setCardStatus("3");
			userCard.setCardCancelTime(new Date());
			bikeMemberUserCardMapper.updateById(userCard);
			//修改状态对象
			BikeMemberUser newMemberData = new BikeMemberUser();
			newMemberData.setStatus(BikeConstant.member_status_logout);
			newMemberData.setId(memberUser.getId());

			if (refundSum.compareTo(new BigDecimal("0"))==1){
				newMemberData.setBalance(new BigDecimal("0"));
				bikeMemberUserMapper.updateById(newMemberData);
				//退款记录
				BikeMemberUserReturn userReturnLog = new BikeMemberUserReturn();
				userReturnLog.setUserId(memberData.getId());
				userReturnLog.setReturnAmount(refundSum);
				userReturnLog.setBalanceEnd(new BigDecimal("0"));
				userReturnLog.setMemo(BikeConstant.member_refund_memo);
				bikeMemberUserReturnMapper.insert(userReturnLog);
				return Result.OK("应退现金："+refundSum+"--销户成功");
			} else {
				bikeMemberUserMapper.updateById(newMemberData);
				return Result.OK("无需退款--销户成功");
			}
		}else {
			String s = this.aliRefund(memberData);
			if (s.equals(BikeConstant.y_n_yes)){
				//修改状态对象
				BikeMemberUser newMemberData = new BikeMemberUser();
				newMemberData.setStatus(BikeConstant.member_status_logout);
				newMemberData.setBalance(new BigDecimal(0));
				newMemberData.setId(memberUser.getId());
				newMemberData.setIdCard(" ");
				bikeMemberUserMapper.updateById(newMemberData);
				//获取其他app  token key
				boolean b1 = redisUtil.hasKey(CommonConstant.PREFIX_USER_TOKEN + memberUser.getCode());
				if (b1) {
					String o = (String) redisUtil.get(CommonConstant.PREFIX_USER_TOKEN + memberUser.getCode());
					if (StringUtils.isNotEmpty(o)) {
						boolean b = redisUtil.hasKey(o);
						// TODO: 2021/9/28 月月鸟的销户清除apptoken
						if (b) {
							redisUtil.del(o);
						}
					}
				}
				//退款记录
				BikeMemberUserReturn userReturnLog = new BikeMemberUserReturn();
				userReturnLog.setUserId(memberData.getId());
				userReturnLog.setReturnAmount(refundSum);
				userReturnLog.setBalanceEnd(new BigDecimal("0"));
				userReturnLog.setMemo(BikeConstant.member_refund_memo);
				bikeMemberUserReturnMapper.insert(userReturnLog);
				return Result.OK("销户成功");
			}else {
				return Result.error(s);
			}
		}

	}

	/**
	 * 充值 支付宝退款
	 * */
	private String aliRefund(BikeMemberUser memberData) {
		//余额
		BigDecimal balanceData = memberData.getBalance();
		double v = balanceData.doubleValue();
		//获取充值记录
		QueryWrapper<BikeMemberUserCharge> wrapper = new QueryWrapper<>();
		wrapper.eq("user_id",memberData.getId());
		List<BikeMemberUserCharge> bikeMemberUserCharges = bikeMemberUserChargeMapper.selectList(wrapper);
		if (bikeMemberUserCharges!=null){
			for (int i = 0 ; i < bikeMemberUserCharges.size() ; i++){
				 Map<String, String> params = new HashMap<>();
				if (v>0){
					BikeMemberUserCharge charge = bikeMemberUserCharges.get(i);
					BigDecimal chargeAmount = charge.getChargeAmount();
					double v1 = chargeAmount.doubleValue();
					//支付宝退款编码
					String outRequestNo = UUID.randomUUID().toString();
					if (v-v1>=0){
						//如果余额-充值金额 大于等于0 则订单全退
						//商户订单号
						params.put("outTradeNo",charge.getOutTradeNo());
						//退款金额
						params.put("refundAmount",chargeAmount.toString());
						//退款原因
						params.put("refundReason","销户");
						//退款请求有号
						params.put("outRequestNo",outRequestNo);
						AlipayTradeRefundResponse refund = AliPayKit.refund(params);
						if (refund!=null){
							if (refund.getCode().equals("10000")){
								v=v-v1;
							}else {
								return charge.getOutTradeNo()+"退款失败";
							}
						}

					}else {
						//如果余额-充值金额 小于0  则 退 余额部分
						//商户订单号
						params.put("outTradeNo",charge.getOutTradeNo());
						//退款金额
						params.put("refundAmount",BigDecimal.valueOf(v).toString());
						//退款原因
						params.put("refundReason","销户");
						//退款请求有号
						params.put("outRequestNo",outRequestNo);
						AlipayTradeRefundResponse refund = AliPayKit.refund(params);
						if (refund.getCode().equals("10000")){
							v=v-v1;
						}else {
							return charge.getOutTradeNo()+"退款失败";
						}
					}
				}
			}
		}
		return BikeConstant.y_n_yes;
	}


	@Override
	public Result<?> delete(String id) {
		BikeMemberUser memberUser = bikeMemberUserMapper.selectById(id);
		if (!memberUser.getStatus().equals(BikeConstant.member_status_logout)){
			return Result.error("注销后才能删除");
		}else {
			bikeMemberUserMapper.deleteById(id);
			return Result.OK();
		}
	}

	@Override
	public String checkRecharge(BikeMemberUser bikeMemberUser) {
		BigDecimal bigDecimal = new BigDecimal(0);
		BikeMemberUser memberUserData = bikeMemberUserMapper.selectById(bikeMemberUser);
		//QueryWrapper<BikeMemberUserCard> wrapper = new QueryWrapper<>();
		//wrapper.eq("user_id",bikeMemberUser.getId());
		//BikeMemberUserCard userCard = bikeMemberUserCardMapper.selectOne(wrapper);
		////判断是否有IC卡
		//if (userCard==null){
		//	return "没有IC卡，无法充值";
		//}
		QueryWrapper<BikeApproveCancel> wrapper = new QueryWrapper<>();
		wrapper.eq("user_id",bikeMemberUser.getId());
		wrapper.eq("approve_status","0");
		BikeApproveCancel selectById = bikeApproveCancelMapper.selectOne(wrapper);
		if (selectById!=null){
			return "已申请销户，无法充值";
		}
		//判断充值金额
		if (bikeMemberUser.getPay().compareTo(bigDecimal) < 0){
			return "充值金额不能小于0！";
		}
		//判断未实名  身份证信息为空
		if (StringUtils.isEmpty(memberUserData.getIdCard())){
			return "请先实名认证";
		}

		//如果用户状态非正常
		if (!memberUserData.getStatus().equals("1")){
			return "用户状态非正常，无法充值";
		}

		return BikeConstant.y_n_yes;
	}

	@Override
	public String checkStatus(String userId) {
		BikeMemberUser memberUser = bikeMemberUserMapper.selectById(userId);
		if (!memberUser.getStatus().equals("1")){
			return "用户状态非正常,无法操作";
		}
		return BikeConstant.y_n_yes;
	}




}
